import 'package:flutter/material.dart';

class SecondPage extends StatelessWidget {
  final String data1;

  const SecondPage({super.key, required this.data1});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('第二页'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text('接收到的参数: $data1'),
            ElevatedButton(
              onPressed: () {
                // 返回上一页，并传递参数
                Navigator.pop(context, '从第二页返回的参数');
              },
              child: Text('返回并传递数据'),
            ),
          ],
        ),
      ),
    );
  }
}
